home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / ODF / Framewrk / FWPart / FWODPart.cpp < prev    next >
Encoding:
Text File  |  1996-09-17  |  56.8 KB  |  2,203 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWODPart.cpp
  4. //    Release Version:    $ ODF 2 $
  5. //
  6. //    Copyright:            (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "FWFrameW.hpp"
  11.  
  12. #ifndef FWODPART_H
  13. #include "FWODPart.h"
  14. #endif
  15.  
  16. #ifndef FWPART_H
  17. #include "FWPart.h"
  18. #endif
  19.  
  20. #ifndef FWKIND_H
  21. #include "FWKind.h"
  22. #endif
  23.  
  24. #ifndef FWPRMISE_H
  25. #include "FWPrmise.h"
  26. #endif
  27.  
  28. #ifndef FWDRGDRP_H
  29. #include "FWDrgDrp.h"
  30. #endif
  31.  
  32. #ifndef FWFRMING_H
  33. #include "FWFrming.h"
  34. #endif
  35.  
  36. #ifndef FWPRTITE_H
  37. #include "FWPrtIte.h"
  38. #endif
  39.  
  40. #ifndef FWPRESEN_H
  41. #include "FWPresen.h"
  42. #endif
  43.  
  44. #ifndef FWPXYFRM_H
  45. #include "FWPxyFrm.h"
  46. #endif
  47.  
  48. #ifndef FWPROXY_H
  49. #include "FWProxy.h"
  50. #endif
  51.  
  52. #ifndef FWLNKMGR_H
  53. #include "FWLnkMgr.h"
  54. #endif
  55.  
  56. #ifndef FWCMD_H
  57. #include "FWCmd.h"
  58. #endif
  59.  
  60. #ifndef FWBARRAY_H
  61. #include "FWBArray.h"
  62. #endif
  63.  
  64. #ifndef FWODGEOM_H
  65. #include "FWODGeom.h"
  66. #endif
  67.  
  68. #ifndef FWMNUBAR_H
  69. #include "FWMnuBar.h"
  70. #endif
  71.  
  72. #ifndef FWUTIL_H
  73. #include "FWUtil.h"
  74. #endif
  75.  
  76. #ifndef FWCLNINF_H
  77. #include "FWClnInf.h"
  78. #endif
  79.  
  80. #ifndef FWDEBUG_H
  81. #include "FWDebug.h"
  82. #endif
  83.  
  84. #ifndef FWEVENTD_H
  85. #include "FWEventD.h"
  86. #endif
  87.  
  88. #ifndef FWLNKITE_H
  89. #include "FWLnkIte.h"
  90. #endif
  91.  
  92. #ifndef FWINTER_H
  93. #include "FWInter.h"
  94. #endif
  95.  
  96. #ifndef FWSESION_H
  97. #include "FWSesion.h"
  98. #endif
  99.  
  100. #ifndef FWSUUTIL_H
  101. #include "FWSUUtil.h"
  102. #endif
  103.  
  104. // ----- OpenDoc Includes -----
  105.  
  106. #ifndef SOM_Module_OpenDoc_Commands_defined
  107. #include <CmdDefs.xh>
  108. #endif
  109.  
  110. #ifndef SOM_ODFrame_xh
  111. #include <Frame.xh>
  112. #endif
  113.  
  114. #ifndef SOM_ODLinkSource_xh
  115. #include <LinkSrc.xh>
  116. #endif
  117.  
  118. #ifndef SOM_ODLink_xh
  119. #include <Link.xh>
  120. #endif
  121.  
  122. #ifndef SOM_ODClipboard_xh
  123. #include <Clipbd.xh>
  124. #endif
  125.  
  126. #ifndef SOM_ODDraft_xh
  127. #include <Draft.xh>
  128. #endif
  129.  
  130. #ifndef SOM_ODSession_xh
  131. #include <ODSessn.xh>
  132. #endif
  133.  
  134. #ifndef SOM_Module_OpenDoc_StdProps_defined
  135. #include <StdProps.xh>
  136. #endif
  137.  
  138. #ifndef SOM_ODArbitrator_xh
  139. #include <Arbitrat.xh>
  140. #endif
  141.  
  142. #ifndef SOM_Module_OpenDoc_Errors_defined
  143. #include <ErrorDef.xh>
  144. #endif
  145.  
  146. //========================================================================================
  147. // Runtime Information
  148. //========================================================================================
  149.  
  150. #ifdef FW_BUILD_MAC
  151. #pragma segment fwpart3
  152. #endif
  153.  
  154. const char* kUnknownExceptionString = "Unknown exception!";
  155.  
  156. //========================================================================================
  157. // class FW_CODPart
  158. //========================================================================================
  159.  
  160. //---------------------------------------------------------------------------------------
  161. //    FW_CODPart::FulfillPromise
  162. //---------------------------------------------------------------------------------------
  163.  
  164. void FW_CODPart::FulfillPromise(Environment *ev, FW_CPart* part, ODStorageUnitView* promiseSUView)
  165. {
  166.     FW_TRY
  167.     {        
  168.         FW_CPromise* promise = NULL;
  169.     
  170.         FW_CByteArray bArray;
  171.         promiseSUView->GetValue(ev, sizeof(FW_CPromise*), bArray);
  172.         bArray.CopyBuffer(&promise, sizeof(FW_CPromise*));
  173.         
  174.         promiseSUView->SetOffset(ev, 0);
  175.         part->GetDataInterchange(ev)->PrivHandleFulfillPromise(ev, promise, promiseSUView);
  176.  
  177.     }
  178.     FW_CATCH_BEGIN
  179.     FW_CATCH_REFERENCE(FW_XException, exception)
  180.     {
  181.         FW_SetException(ev, exception);
  182.     }
  183.     FW_CATCH_EVERYTHING()
  184.     {
  185.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  186.         FW_SetEvError(ev, kODErrUndefined);
  187.     }
  188.     FW_CATCH_END
  189. }
  190.  
  191. //---------------------------------------------------------------------------------------
  192. //    FW_CODPart::DragEnter
  193. //---------------------------------------------------------------------------------------
  194.  
  195. ODDragResult FW_CODPart::DragEnter(Environment *ev,
  196.                                     ODDragItemIterator* dragInfo,
  197.                                     ODFacet* facet,
  198.                                     const FW_CPoint& where)
  199. {
  200.     ODDragResult result = FALSE;
  201.     
  202.     FW_TRY
  203.     {
  204.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, facet->GetFrame(ev));
  205.         FW_ASSERT(frame);
  206.         FW_MDroppableFrame* droppable = frame->GetDroppable(ev);
  207.         if (droppable)
  208.             result = droppable->DragEnter(ev, facet, dragInfo, where);
  209.     }
  210.     FW_CATCH_BEGIN
  211.     FW_CATCH_REFERENCE(FW_XException, exception)
  212.     {
  213.         FW_SetException(ev, exception);
  214.     }
  215.     FW_CATCH_EVERYTHING()
  216.     {
  217.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  218.         FW_SetEvError(ev, kODErrUndefined);
  219.     }
  220.     FW_CATCH_END
  221.     
  222.     return result;
  223. }
  224.  
  225. //---------------------------------------------------------------------------------------
  226. //    FW_CODPart::DragWithin
  227. //---------------------------------------------------------------------------------------
  228.  
  229. ODDragResult FW_CODPart::DragWithin(Environment *ev,
  230.                                         ODDragItemIterator* dragInfo,
  231.                                         ODFacet* facet,
  232.                                         const FW_CPoint& where)
  233. {
  234.     ODDragResult result = FALSE;
  235.  
  236.     FW_TRY
  237.     {
  238.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, facet->GetFrame(ev));
  239.         FW_ASSERT(frame);
  240.         FW_MDroppableFrame* droppable = frame->GetDroppable(ev);
  241.         if (droppable)
  242.             result = droppable->DragWithin(ev, facet, dragInfo, where);
  243.     }
  244.     FW_CATCH_BEGIN
  245.     FW_CATCH_REFERENCE(FW_XException, exception)
  246.     {
  247.         FW_SetException(ev, exception);
  248.     }
  249.     FW_CATCH_EVERYTHING()
  250.     {
  251.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  252.         FW_SetEvError(ev, kODErrUndefined);
  253.     }
  254.     FW_CATCH_END
  255.     
  256.     return result;
  257. }
  258.  
  259. //---------------------------------------------------------------------------------------
  260. //    FW_CODPart::DragLeave
  261. //---------------------------------------------------------------------------------------
  262.  
  263. void FW_CODPart::DragLeave(Environment *ev,
  264.                             ODFacet* facet,
  265.                             const FW_CPoint& where)
  266. {
  267.     FW_TRY
  268.     {
  269.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, facet->GetFrame(ev));
  270.         FW_ASSERT(frame);
  271.         FW_MDroppableFrame* droppable = frame->GetDroppable(ev);
  272.         if (droppable)
  273.             droppable->DragLeave(ev, facet, where);
  274.     }
  275.     FW_CATCH_BEGIN
  276.     FW_CATCH_REFERENCE(FW_XException, exception)
  277.     {
  278.         FW_SetException(ev, exception);
  279.     }
  280.     FW_CATCH_EVERYTHING()
  281.     {
  282.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  283.         FW_SetEvError(ev, kODErrUndefined);
  284.     }
  285.     FW_CATCH_END
  286. }
  287.  
  288. //---------------------------------------------------------------------------------------
  289. //    FW_CODPart::Drop
  290. //---------------------------------------------------------------------------------------
  291.  
  292. ODDropResult FW_CODPart::Drop(Environment *ev,
  293.                                 ODDragItemIterator* dropInfo,
  294.                                 ODFacet* facet,
  295.                                 const FW_CPoint& where)
  296. {
  297.     ODDropResult result = kODDropFail;
  298.     
  299.     FW_TRY
  300.     {
  301.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, facet->GetFrame(ev));
  302.         FW_ASSERT(frame);
  303.         FW_MDroppableFrame* droppable = frame->GetDroppable(ev);
  304.         if (droppable)
  305.             result = droppable->Drop(ev, dropInfo, facet, where);
  306.     }
  307.     FW_CATCH_BEGIN
  308.     FW_CATCH_REFERENCE(FW_XException, exception)
  309.     {
  310.         FW_SetException(ev, exception);
  311.     }
  312.     FW_CATCH_EVERYTHING()
  313.     {
  314.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  315.         FW_SetEvError(ev, kODErrUndefined);
  316.     }
  317.     FW_CATCH_END
  318.     
  319.     return result;
  320. }
  321.  
  322. //---------------------------------------------------------------------------------------
  323. //    FW_CODPart::DropCompleted
  324. //---------------------------------------------------------------------------------------
  325.  
  326. void FW_CODPart::DropCompleted(Environment *ev,
  327.                                 ODPart* destPart,
  328.                                 ODDropResult dropResult)
  329. {
  330. FW_UNUSED(destPart);
  331. FW_UNUSED(dropResult);
  332.     FW_TRY
  333.     {
  334.         FW_DEBUG_MESSAGE("DropCompleted: Not Yet Implemented");
  335.     }
  336.     FW_CATCH_BEGIN
  337.     FW_CATCH_REFERENCE(FW_XException, exception)
  338.     {
  339.         FW_SetException(ev, exception);
  340.     }
  341.     FW_CATCH_EVERYTHING()
  342.     {
  343.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  344.         FW_SetEvError(ev, kODErrUndefined);
  345.     }
  346.     FW_CATCH_END
  347. }
  348.  
  349. //---------------------------------------------------------------------------------------
  350. //    FW_CODPart::ContainingPartPropertiesUpdated
  351. //---------------------------------------------------------------------------------------
  352.  
  353. void FW_CODPart::ContainingPartPropertiesUpdated(Environment *ev,
  354.                                                     ODFrame* odFrame,
  355.                                                     ODStorageUnit* propertyUnit)
  356. {
  357.     FW_TRY
  358.     {
  359.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, odFrame);
  360.         FW_ASSERT(frame);
  361.         if (frame->GetAdoptsContainerProperties(ev))
  362.             frame->AdoptContainingPartProperties(ev, propertyUnit);
  363.     }
  364.     FW_CATCH_BEGIN
  365.     FW_CATCH_REFERENCE(FW_XException, exception)
  366.     {
  367.         FW_SetException(ev, exception);
  368.     }
  369.     FW_CATCH_EVERYTHING()
  370.     {
  371.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  372.         FW_SetEvError(ev, kODErrUndefined);
  373.     }
  374.     FW_CATCH_END
  375. }
  376.  
  377. //---------------------------------------------------------------------------------------
  378. //    FW_CODPart::AcquireContainingPartProperties
  379. //---------------------------------------------------------------------------------------
  380.  
  381. ODStorageUnit* FW_CODPart::AcquireContainingPartProperties(Environment *ev, 
  382.                                                         FW_CEmbeddingPart* embeddingPart,
  383.                                                         ODFrame* embeddedFrame)
  384. {
  385.     ODStorageUnit* su = NULL;
  386.     
  387.     FW_TRY
  388.     {
  389.         su = embeddingPart->AcquireContainingPartProperties(ev, embeddedFrame);
  390.     }
  391.     FW_CATCH_BEGIN
  392.     FW_CATCH_REFERENCE(FW_XException, exception)
  393.     {
  394.         FW_SetException(ev, exception);
  395.     }
  396.     FW_CATCH_EVERYTHING()
  397.     {
  398.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  399.         FW_SetEvError(ev, kODErrUndefined);
  400.     }
  401.     FW_CATCH_END
  402.     
  403.     return su;
  404. }
  405.  
  406. //---------------------------------------------------------------------------------------
  407. //    FW_CODPart::RevealFrame
  408. //---------------------------------------------------------------------------------------
  409.  
  410. FW_Boolean FW_CODPart::RevealFrame(Environment *ev,
  411.                                     FW_CEmbeddingPart* part,
  412.                                     ODFrame* embeddedFrame,
  413.                                     ODShape* revealShape)
  414. {
  415.     ODBoolean result = FALSE;
  416.     
  417.     FW_TRY
  418.     {
  419.         FW_CAcquiredODFrame aqContainingFrame = embeddedFrame->AcquireContainingFrame(ev);
  420.         FW_CEmbeddingFrame* embeddingFrame = FW_CEmbeddingFrame::ODtoFWEmbeddingFrame(ev, aqContainingFrame);
  421.         FW_ASSERT(embeddingFrame);
  422.         
  423.         FW_MProxy* proxy = part->GetProxy(ev, embeddedFrame);
  424.         FW_ASSERT(proxy);
  425.         result = proxy->Reveal(ev, embeddingFrame, embeddedFrame, revealShape);
  426.     }
  427.     FW_CATCH_BEGIN
  428.     FW_CATCH_REFERENCE(FW_XException, exception)
  429.     {
  430.         FW_SetException(ev, exception);
  431.     }
  432.     FW_CATCH_EVERYTHING()
  433.     {
  434.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  435.         FW_SetEvError(ev, kODErrUndefined);
  436.     }
  437.     FW_CATCH_END
  438.     
  439.     return result;
  440. }
  441.  
  442. //---------------------------------------------------------------------------------------
  443. //    FW_CODPart::DisplayFrameAdded
  444. //---------------------------------------------------------------------------------------
  445.  
  446. void FW_CODPart::DisplayFrameAdded(Environment *ev,
  447.                                     FW_CPart* part, 
  448.                                     ODFrame* odFrame)
  449. {
  450.     FW_TRY
  451.     {
  452.         // ----- Create a global shape and transform if neccessary -----
  453.         FW_PrivSetShapeTransformMaker(ev, odFrame);
  454.     
  455.         // ----- Look for the presentation -----
  456.         FW_CPresentation* newPresentation = part->PrivGetPresentation(ev, odFrame);
  457.         
  458.         // [HLX] I used SetPresentation and not ChangePresentation because the frame is
  459.         // not yet part of my list of display frame
  460.         odFrame->SetPresentation(ev, newPresentation->GetPresentationType(ev));
  461.     
  462.         // ----- Create the frame -----
  463.         FW_CFrame* frame = newPresentation->PrivNewFrame(ev, odFrame, FALSE);
  464.         if (frame == NULL)
  465.             frame = part->NewFrame(ev, odFrame,  newPresentation, FALSE);
  466.         
  467.         // ----- Create the part Info -----
  468. //        odFrame->SetPartInfo(ev, (ODInfoType)frame);
  469.     
  470.         // ----- Notify the frame -----
  471.         frame->FrameAdded(ev, odFrame, FALSE);    // brand new frame
  472.     }
  473.     FW_CATCH_BEGIN
  474.     FW_CATCH_REFERENCE(FW_XException, exception)
  475.     {
  476.         FW_SetException(ev, exception);
  477.     }
  478.     FW_CATCH_EVERYTHING()
  479.     {
  480.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  481.         FW_SetEvError(ev, kODErrUndefined);
  482.     }
  483.     FW_CATCH_END
  484. }
  485.  
  486. //---------------------------------------------------------------------------------------
  487. //    FW_CODPart::AttachSourceFrame
  488. //---------------------------------------------------------------------------------------
  489.  
  490. void FW_CODPart::AttachSourceFrame(Environment *ev,
  491.                                     ODFrame* odFrame,
  492.                                     ODFrame* odSourceFrame)
  493. {
  494.     FW_TRY
  495.     {
  496.         if (odSourceFrame != NULL && odFrame != NULL)
  497.         {
  498.             FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, odFrame);
  499.             FW_ASSERT(frame);
  500.             
  501.             FW_CFrame* sourceFrame = FW_CFrame::ODtoFWFrame(ev, odSourceFrame);
  502.             FW_ASSERT(sourceFrame != NULL);
  503.             
  504.             frame->PrivAttachSourceFrame(ev, sourceFrame);
  505.         }
  506.     }
  507.     FW_CATCH_BEGIN
  508.     FW_CATCH_REFERENCE(FW_XException, exception)
  509.     {
  510.         FW_SetException(ev, exception);
  511.     }
  512.     FW_CATCH_EVERYTHING()
  513.     {
  514.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  515.         FW_SetEvError(ev, kODErrUndefined);
  516.     }
  517.     FW_CATCH_END
  518. }
  519.  
  520. //---------------------------------------------------------------------------------------
  521. //    FW_CODPart::DisplayFrameRemoved
  522. //---------------------------------------------------------------------------------------
  523.  
  524. void FW_CODPart::DisplayFrameRemoved(Environment *ev,
  525.                                     FW_CPart* part,
  526.                                     ODFrame* odFrame,
  527.                                     FW_Boolean toStorage)
  528. {
  529.     FW_TRY
  530.     {
  531.         part->PrivDisplayFrameRemoved(ev, odFrame, toStorage);            
  532.     }
  533.     FW_CATCH_BEGIN
  534.     FW_CATCH_REFERENCE(FW_XException, exception)
  535.     {
  536.         FW_SetException(ev, exception);
  537.     }
  538.     FW_CATCH_EVERYTHING()
  539.     {
  540.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  541.         FW_SetEvError(ev, kODErrUndefined);
  542.     }
  543.     FW_CATCH_END
  544. }
  545.  
  546. //---------------------------------------------------------------------------------------
  547. //    FW_CODPart::DisplayFrameConnected
  548. //---------------------------------------------------------------------------------------
  549.  
  550. void FW_CODPart::DisplayFrameConnected(Environment *ev,
  551.                                         ODFrame* odFrame)
  552. {
  553.     FW_TRY
  554.     {
  555.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, odFrame);
  556.         FW_ASSERT(frame);
  557.         
  558.         // ----- Notify the frame
  559.         frame->FrameAdded(ev, odFrame, TRUE);  // From storage
  560.     }
  561.     FW_CATCH_BEGIN
  562.     FW_CATCH_REFERENCE(FW_XException, exception)
  563.     {
  564.         FW_SetException(ev, exception);
  565.     }
  566.     FW_CATCH_EVERYTHING()
  567.     {
  568.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  569.         FW_SetEvError(ev, kODErrUndefined);
  570.     }
  571.     FW_CATCH_END
  572. }
  573.  
  574. //---------------------------------------------------------------------------------------
  575. //    FW_CODPart::FrameShapeChanged
  576. //---------------------------------------------------------------------------------------
  577.  
  578. void FW_CODPart::FrameShapeChanged(Environment *ev,
  579.                                     ODFrame* odFrame)
  580. {
  581.     FW_TRY
  582.     {
  583.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, odFrame);
  584.         FW_ASSERT(frame != NULL);
  585.     
  586.         frame->FrameShapeChanged(ev);
  587.     }
  588.     FW_CATCH_BEGIN
  589.     FW_CATCH_REFERENCE(FW_XException, exception)
  590.     {
  591.         FW_SetException(ev, exception);
  592.     }
  593.     FW_CATCH_EVERYTHING()
  594.     {
  595.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  596.         FW_SetEvError(ev, kODErrUndefined);
  597.     }
  598.     FW_CATCH_END
  599. }
  600.  
  601. //---------------------------------------------------------------------------------------
  602. //    FW_CODPart::ViewTypeChanged
  603. //---------------------------------------------------------------------------------------
  604.  
  605. void FW_CODPart::ViewTypeChanged(Environment *ev,
  606.                                     ODFrame* odFrame)
  607. {
  608.     FW_TRY
  609.     {
  610.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, odFrame);
  611.         FW_ASSERT(frame != NULL);
  612.         
  613.         ODTypeToken newViewType = odFrame->GetViewType(ev);
  614.         ODTypeToken oldViewType = frame->PrivGetPreviousViewType(ev);
  615.         
  616.         if (newViewType != oldViewType)
  617.         {
  618.             frame->PrivSetPreviousViewType(ev, newViewType);
  619.             frame->ViewTypeChanged(ev, newViewType, oldViewType);
  620.         }
  621.     }
  622.     FW_CATCH_BEGIN
  623.     FW_CATCH_REFERENCE(FW_XException, exception)
  624.     {
  625.         FW_SetException(ev, exception);
  626.     }
  627.     FW_CATCH_EVERYTHING()
  628.     {
  629.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  630.         FW_SetEvError(ev, kODErrUndefined);
  631.     }
  632.     FW_CATCH_END
  633. }
  634.  
  635. //---------------------------------------------------------------------------------------
  636. //    FW_CODPart::PresentationChanged
  637. //---------------------------------------------------------------------------------------
  638.  
  639. void FW_CODPart::PresentationChanged(Environment *ev,
  640.                                         ODFrame* odFrame)
  641. {
  642.     FW_TRY
  643.     {
  644.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, odFrame);
  645.         FW_ASSERT(frame != NULL);
  646.     
  647.         frame->PresentationChanged(ev);
  648.     }
  649.     FW_CATCH_BEGIN
  650.     FW_CATCH_REFERENCE(FW_XException, exception)
  651.     {
  652.         FW_SetException(ev, exception);
  653.     }
  654.     FW_CATCH_EVERYTHING()
  655.     {
  656.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  657.         FW_SetEvError(ev, kODErrUndefined);
  658.     }
  659.     FW_CATCH_END
  660. }
  661.  
  662. //---------------------------------------------------------------------------------------
  663. //    FW_CODPart::SequenceChanged
  664. //---------------------------------------------------------------------------------------
  665.  
  666. void FW_CODPart::SequenceChanged(Environment *ev,
  667.                                     ODFrame* odFrame)
  668. {
  669.     FW_TRY
  670.     {
  671.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, odFrame);
  672.         FW_ASSERT(frame != NULL);
  673.     
  674.         frame->SequenceChanged(ev);
  675.     }
  676.     FW_CATCH_BEGIN
  677.     FW_CATCH_REFERENCE(FW_XException, exception)
  678.     {
  679.         FW_SetException(ev, exception);
  680.     }
  681.     FW_CATCH_EVERYTHING()
  682.     {
  683.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  684.         FW_SetEvError(ev, kODErrUndefined);
  685.     }
  686.     FW_CATCH_END
  687. }
  688.  
  689. //---------------------------------------------------------------------------------------
  690. //    FW_CODPart::WritePartInfo
  691. //---------------------------------------------------------------------------------------
  692.  
  693. void FW_CODPart::WritePartInfo(Environment *ev,
  694.                                     ODInfoType partInfo,
  695.                                     ODStorageUnitView* storageUnitView)
  696. {
  697.     FW_TRY
  698.     {
  699.         FW_ASSERT(partInfo != NULL);
  700.     
  701.         FW_CFrame* frame = (FW_CFrame*) partInfo;
  702.         FW_ASSERT(frame);
  703.         
  704.         ODStorageUnit* su = storageUnitView->GetStorageUnit(ev);
  705.  
  706.         FW_CAcquireODPropertyName propName(ev, storageUnitView);
  707.         FW_SUForceFocus(ev, su, propName, frame->GetPart(ev)->GetPartKind(ev)->GetType(ev));
  708.         
  709.         FW_CAcquireODStorageUnitView suView(ev, su);
  710.         frame->PrivExternalizeFrame(ev, suView);        // framework info
  711.         frame->ExternalizeFrame(ev, suView);            // user info
  712.     }
  713.     FW_CATCH_BEGIN
  714.     FW_CATCH_REFERENCE(FW_XException, exception)
  715.     {
  716.         FW_SetException(ev, exception);
  717.     }
  718.     FW_CATCH_EVERYTHING()
  719.     {
  720.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  721.         FW_SetEvError(ev, kODErrUndefined);
  722.     }
  723.     FW_CATCH_END
  724. }
  725.  
  726. //---------------------------------------------------------------------------------------
  727. //    FW_CODPart::ReadPartInfo
  728. //---------------------------------------------------------------------------------------
  729.  
  730. ODInfoType FW_CODPart::ReadPartInfo(Environment *ev,
  731.                                     FW_CPart* part, 
  732.                                     ODFrame* odFrame,
  733.                                     ODStorageUnitView* storageUnitView)
  734. {
  735.     FW_CFrame* frame = NULL;
  736.     
  737.     FW_TRY
  738.     {
  739.         // ----- Create a global shape and transform if neccessary -----
  740.         FW_PrivSetShapeTransformMaker(ev, odFrame);
  741.     
  742.         // ----- Determine the presentation -----
  743.         FW_CPresentation* presentation = part->PrivGetPresentation(ev, odFrame);
  744.         // [HLX] I used SetPresentation and not ChangePresentation because the frame is
  745.         // not yet part of my list of display frame
  746.         odFrame->SetPresentation(ev, presentation->GetPresentationType(ev));
  747.     
  748.         // ----- Create the FW_CFrame object -----
  749.         frame = presentation->PrivNewFrame(ev, odFrame, TRUE);
  750.         if (frame == NULL)
  751.             frame = part->NewFrame(ev, odFrame, presentation, TRUE);
  752.         
  753.         // ----- Internalize the frame -----
  754.         ODStorageUnit* su = storageUnitView->GetStorageUnit(ev);
  755.     
  756.         FW_CAcquireODPropertyName propName(ev, storageUnitView);
  757.         
  758.         if (FW_SUExistsThenFocus(ev, su, propName, frame->GetPart(ev)->GetPartKind(ev)->GetType(ev)) )
  759.         {
  760.             FW_CAcquireODStorageUnitView suView(ev, su);
  761.             frame->PrivInternalizeFrame(ev, suView);        // framework info
  762.             frame->InternalizeFrame(ev, suView);            // user info
  763.         }
  764.     }
  765.     FW_CATCH_BEGIN
  766.     FW_CATCH_REFERENCE(FW_XException, exception)
  767.     {
  768.         FW_SetException(ev, exception);
  769.     }
  770.     FW_CATCH_EVERYTHING()
  771.     {
  772.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  773.         FW_SetEvError(ev, kODErrUndefined);
  774.     }
  775.     FW_CATCH_END
  776.     
  777.     return (ODInfoType)frame;
  778. }
  779.  
  780. //---------------------------------------------------------------------------------------
  781. //    FW_CODPart::ClonePartInfo
  782. //---------------------------------------------------------------------------------------
  783.  
  784. void FW_CODPart::ClonePartInfo(Environment *ev,
  785.                                 ODDraftKey key,
  786.                                 ODInfoType partInfo,
  787.                                 ODStorageUnitView* storageUnitView,
  788.                                 ODFrame* scope)
  789. {
  790.     FW_TRY
  791.     {
  792.         FW_ASSERT(partInfo != NULL);
  793.     
  794.         FW_CFrame* frame = (FW_CFrame*) partInfo;
  795.         FW_ASSERT(frame);
  796.         
  797.         ODStorageUnit* su = storageUnitView->GetStorageUnit(ev);
  798.  
  799.         FW_CAcquireODPropertyName propName(ev, storageUnitView);
  800.         FW_SUForceFocus(ev, su, propName, frame->GetPart(ev)->GetPartKind(ev)->GetType(ev));
  801.         
  802.         FW_CAcquireODStorageUnitView suView(ev, su);
  803.         frame->PrivExternalizeFrame(ev, suView);        // framework info
  804.             
  805.         frame->ClonePartInfo(ev, key, partInfo, suView, scope);     // user info
  806.     }
  807.     FW_CATCH_BEGIN
  808.     FW_CATCH_REFERENCE(FW_XException, exception)
  809.     {
  810.         FW_SetException(ev, exception);
  811.     }
  812.     FW_CATCH_EVERYTHING()
  813.     {
  814.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  815.         FW_SetEvError(ev, kODErrUndefined);
  816.     }
  817.     FW_CATCH_END
  818. }
  819.  
  820. //---------------------------------------------------------------------------------------
  821. //    FW_CODPart::Open
  822. //---------------------------------------------------------------------------------------
  823. //    if odFrame is != of NULL we are opening the window from storage. If odFrame == NULL it
  824. //    is the first time.
  825.  
  826. ODID FW_CODPart::Open(Environment *ev,
  827.                         FW_CPart* part,
  828.                         ODFrame* odFrame)
  829. {
  830.     ODID id = 0;
  831.     
  832.     FW_TRY
  833.     {
  834.         FW_CWindow* window = NULL;
  835.         
  836.         if (odFrame)
  837.         {
  838.             if (odFrame->IsRoot(ev))
  839.             {
  840.                 window = new FW_CWindow(ev, odFrame);
  841.             }
  842.             else
  843.             {
  844.                 FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, odFrame);
  845.                 FW_ASSERT(frame != NULL);
  846.                 return part->OpenPartWindow(ev, frame, NULL);
  847.             }
  848.         }
  849.         else
  850.         {
  851.             window = part->NewDocumentWindow(ev);
  852.         }
  853.         FW_ASSERT(window);
  854.             
  855.         // ATTENTION: the order is very important
  856.         window->Show(ev);
  857.         window->Select(ev);
  858.     
  859.         id = window->GetID(ev);
  860.     }
  861.     FW_CATCH_BEGIN
  862.     FW_CATCH_REFERENCE(FW_XException, exception)
  863.     {
  864.         FW_SetException(ev, exception);
  865.     }
  866.     FW_CATCH_EVERYTHING()
  867.     {
  868.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  869.         FW_SetEvError(ev, kODErrUndefined);
  870.     }
  871.     FW_CATCH_END
  872.     
  873.     return id;
  874. }
  875.  
  876. //---------------------------------------------------------------------------------------
  877. //    FW_CODPart::RequestEmbeddedFrame
  878. //---------------------------------------------------------------------------------------
  879.  
  880. ODFrame* FW_CODPart::RequestEmbeddedFrame(Environment *ev,
  881.                                             FW_CEmbeddingPart* part,
  882.                                             ODFrame* containingFrame,
  883.                                             ODFrame* baseFrame,
  884.                                             ODShape* suggestedFrameShape,
  885.                                             ODPart* embeddedPart,
  886.                                             ODTypeToken viewType,
  887.                                             ODTypeToken presentation,
  888.                                             FW_Boolean isOverlaid)
  889. {
  890.     ODFrame* frame = NULL;
  891.     
  892.     FW_TRY
  893.     {
  894.         FW_CEmbeddingFrame* embeddingFrame = FW_CEmbeddingFrame::ODtoFWEmbeddingFrame(ev, containingFrame);
  895.         FW_ASSERT(embeddingFrame);
  896.     
  897.         FW_MProxy* baseProxy = part->GetProxy(ev, baseFrame);
  898.         FW_ASSERT(baseProxy);
  899.         
  900.         FW_ASSERT(baseFrame->GetFrameGroup(ev) == baseProxy->GetFrameGroup(ev));
  901.         ODID frameGroup = baseProxy->GetFrameGroup(ev);
  902.         FW_ASSERT(baseFrame->GetFrameGroup(ev) == frameGroup);
  903.         
  904.         FW_Boolean hasAGroup = (frameGroup != 0);
  905.         
  906.         if (!hasAGroup)
  907.         {
  908.             FW_ASSERT(baseProxy->GetSequenceNumber(ev) == 0);            
  909.             frameGroup = part->PrivGetNextFrameGroup(ev);        
  910.         }
  911.         
  912.         // ----- Call the frame -----
  913.         FW_MProxy* proxy = embeddingFrame->EmbeddedFrameRequested(ev, 
  914.                                                                 baseProxy,
  915.                                                                 baseFrame, 
  916.                                                                 suggestedFrameShape, 
  917.                                                                 embeddedPart, 
  918.                                                                 viewType, 
  919.                                                                 presentation, 
  920.                                                                 frameGroup, 
  921.                                                                 isOverlaid, 
  922.                                                                 baseFrame->IsSubframe(ev));
  923.         if (proxy == NULL)
  924.             return NULL;    // RequestEmbeddedFrame not supported
  925.         
  926.         ODID newSequenceNumber = 0;
  927.         // ----- Set the group and sequence -----
  928.         if (!hasAGroup)
  929.         {
  930.             baseProxy->PrivSetFrameGroup(ev, frameGroup);
  931.             baseProxy->ChangeSequenceNumber(ev, 1);
  932.             newSequenceNumber = 1;
  933.         }
  934.         else
  935.         {
  936.             // ----- Look for the highest sequence number ------
  937.             newSequenceNumber = 0;
  938.             FW_CPartProxyIterator ite(part);
  939.             for (FW_MProxy* aProxy = ite.First(); ite.IsNotComplete(); aProxy = ite.Next())
  940.             {
  941.                 if (aProxy->GetFrameGroup(ev) == frameGroup)
  942.                 {
  943.                     ODID sequenceNumber = aProxy->GetSequenceNumber(ev);
  944.                     if (sequenceNumber > newSequenceNumber)
  945.                         newSequenceNumber = sequenceNumber;
  946.                 }
  947.             }
  948.         }
  949.  
  950.         newSequenceNumber++;
  951.         proxy->PrivSetFrameGroup(ev, frameGroup);
  952.         proxy->ChangeSequenceNumber(ev, newSequenceNumber);
  953.                 
  954.         frame = proxy->AcquireEmbeddedFrame(ev, embeddingFrame);
  955.     }
  956.     FW_CATCH_BEGIN
  957.     FW_CATCH_REFERENCE(FW_XException, exception)
  958.     {
  959.         FW_SetException(ev, exception);
  960.     }
  961.     FW_CATCH_EVERYTHING()
  962.     {
  963.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  964.         FW_SetEvError(ev, kODErrUndefined);
  965.     }
  966.     FW_CATCH_END
  967.     
  968.     return frame;
  969. }
  970.  
  971. //---------------------------------------------------------------------------------------
  972. //    FW_CODPart::RemoveEmbeddedFrame
  973. //---------------------------------------------------------------------------------------
  974.  
  975. void FW_CODPart::RemoveEmbeddedFrame(Environment *ev,
  976.                                     FW_CEmbeddingPart* part,
  977.                                     ODFrame* embeddedFrame)
  978. {
  979.     FW_TRY
  980.     {
  981.         FW_CAcquiredODFrame aqODContainingFrame = embeddedFrame->AcquireContainingFrame(ev);
  982.         FW_CEmbeddingFrame* containingFrame = FW_CEmbeddingFrame::ODtoFWEmbeddingFrame(ev, aqODContainingFrame);
  983.         FW_ASSERT(containingFrame != NULL);
  984.         
  985.         // ----- Find the proxy -----
  986.         FW_MProxy* proxy = containingFrame->GetProxy(ev, embeddedFrame);
  987.         FW_ASSERT(proxy != NULL);
  988.         
  989.         proxy->RemoveEmbeddedFrames(ev);        // remove all embedded frames
  990.  
  991.         // ----- Save frame group and sequence number -----
  992.         ODID sequenceNumber = proxy->GetSequenceNumber(ev);
  993.         ODID frameGroup = proxy->GetFrameGroup(ev);
  994.  
  995.         // ----- Ask the part to delete it -----
  996.         part->EmbeddedFrameRemoved(ev, proxy);    
  997.  
  998.         // ------ Deal with frame group and sequence number
  999.         FW_MProxy* lonelyProxy = NULL;
  1000.         unsigned short count = 0;
  1001.         FW_CPartProxyIterator ite(part);
  1002.         for (FW_MProxy* aProxy = ite.First(); ite.IsNotComplete(); aProxy = ite.Next())
  1003.         {
  1004.             if (aProxy->GetFrameGroup(ev) == frameGroup)
  1005.             {
  1006.                 count++;
  1007.                 lonelyProxy =  aProxy;
  1008.                 ODID aSequenceNumber = aProxy->GetSequenceNumber(ev);
  1009.                 if (aSequenceNumber > sequenceNumber)
  1010.                     aProxy->ChangeSequenceNumber(ev, aSequenceNumber-1);
  1011.             }
  1012.         }
  1013.         
  1014.         // ----- In the case where I am the only proxy of this group change it back to 0 -----
  1015.         if (count == 1)
  1016.         {
  1017.             lonelyProxy->PrivSetFrameGroup(ev, 0);
  1018.             lonelyProxy->ChangeSequenceNumber(ev, 0);
  1019.         }
  1020.     }
  1021.     FW_CATCH_BEGIN
  1022.     FW_CATCH_REFERENCE(FW_XException, exception)
  1023.     {
  1024.         FW_SetException(ev, exception);
  1025.     }
  1026.     FW_CATCH_EVERYTHING()
  1027.     {
  1028.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1029.         FW_SetEvError(ev, kODErrUndefined);
  1030.     }
  1031.     FW_CATCH_END
  1032. }
  1033.  
  1034. //---------------------------------------------------------------------------------------
  1035. //    FW_CODPart::RequestFrameShape
  1036. //---------------------------------------------------------------------------------------
  1037.  
  1038. ODShape* FW_CODPart::RequestFrameShape(Environment *ev,
  1039.                                         ODFrame* embeddedFrame,
  1040.                                         ODShape* frameShape)
  1041. {
  1042.     ODShape* newFrameShape = NULL;
  1043.     
  1044.     FW_TRY
  1045.     {
  1046.         FW_CAcquiredODFrame aqODContainingFrame = embeddedFrame->AcquireContainingFrame(ev);
  1047.         
  1048.         FW_CEmbeddingFrame* containingFrame = FW_CEmbeddingFrame::ODtoFWEmbeddingFrame(ev, aqODContainingFrame);
  1049.         FW_ASSERT(containingFrame);
  1050.         
  1051.         FW_MProxy* proxy = containingFrame->GetProxy(ev, embeddedFrame);
  1052.         FW_ASSERT(proxy);
  1053.         
  1054.         newFrameShape = proxy->FrameShapeRequested(ev, containingFrame, embeddedFrame, frameShape);
  1055.     }
  1056.     FW_CATCH_BEGIN
  1057.     FW_CATCH_REFERENCE(FW_XException, exception)
  1058.     {
  1059.         FW_SetException(ev, exception);
  1060.     }
  1061.     FW_CATCH_EVERYTHING()
  1062.     {
  1063.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1064.         FW_SetEvError(ev, kODErrUndefined);
  1065.     }
  1066.     FW_CATCH_END
  1067.     
  1068.     return newFrameShape;
  1069. }
  1070.  
  1071. //---------------------------------------------------------------------------------------
  1072. //    FW_CODPart::UsedShapeChanged
  1073. //---------------------------------------------------------------------------------------
  1074.  
  1075. void FW_CODPart::UsedShapeChanged(Environment *ev,
  1076.                                     ODFrame* embeddedFrame)
  1077. {
  1078.     FW_TRY
  1079.     {
  1080.         FW_CAcquiredODFrame aqContainingFrame = embeddedFrame->AcquireContainingFrame(ev);
  1081.         FW_CEmbeddingFrame *containingFrame = FW_CEmbeddingFrame::ODtoFWEmbeddingFrame(ev, aqContainingFrame);    
  1082.         FW_ASSERT(containingFrame != NULL);    // Should not be called if not an embedding frame or not one of our frame
  1083.     
  1084.         FW_MProxy* proxy = containingFrame->GetProxy(ev, embeddedFrame);
  1085.         
  1086.         //     If proxy is null it means that the embedded part is changing its used shape before
  1087.         //    I had time to finish building all my structures 
  1088.         if (proxy != NULL)
  1089.             proxy->UsedShapeChanged(ev, containingFrame, embeddedFrame);
  1090.     }
  1091.     FW_CATCH_BEGIN
  1092.     FW_CATCH_REFERENCE(FW_XException, exception)
  1093.     {
  1094.         FW_SetException(ev, exception);
  1095.     }
  1096.     FW_CATCH_EVERYTHING()
  1097.     {
  1098.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1099.         FW_SetEvError(ev, kODErrUndefined);
  1100.     }
  1101.     FW_CATCH_END
  1102. }
  1103.  
  1104. //---------------------------------------------------------------------------------------
  1105. //    FW_CODPart::AdjustBorderShape
  1106. //---------------------------------------------------------------------------------------
  1107.  
  1108. ODShape* FW_CODPart::AdjustBorderShape(Environment *ev,
  1109.                                         ODFacet* embeddedFacet,
  1110.                                         ODShape* shape)
  1111. {
  1112.     FW_TRY
  1113.     {    
  1114.         ODFrame* embeddedFrame = embeddedFacet->GetFrame(ev);
  1115.         FW_CAcquiredODFrame aqContainingFrame = embeddedFrame->AcquireContainingFrame(ev);
  1116.         FW_CEmbeddingFrame *containingFrame = FW_CEmbeddingFrame::ODtoFWEmbeddingFrame(ev, aqContainingFrame);    
  1117.         FW_ASSERT(containingFrame != NULL);    // Should not be called if not an embedding frame or not one of our frame
  1118.         
  1119.         FW_MProxy* proxy = containingFrame->GetProxy(ev, embeddedFrame);
  1120.         FW_ASSERT(proxy);            
  1121.         FW_CProxyFrame* proxyFrame = proxy->GetProxyFrame(ev, embeddedFrame->GetID(ev));
  1122.         
  1123.         FW_CAcquiredODTransform tempx;
  1124.         
  1125.         if (shape != NULL)
  1126.         {            
  1127.             // ----- I need to acquire it before returning it -----        
  1128.             shape->Acquire(ev);
  1129.  
  1130.             // ----- Get transform to go from content to embedding content coordinates -----
  1131.             tempx = FW_CopyAndRelease(ev, containingFrame->AcquireInternalTransform(ev, NULL));
  1132.             FW_CAcquiredODTransform aqExternalxForm = embeddedFacet->AcquireExternalTransform(ev, NULL);
  1133.             tempx->PostCompose(ev, aqExternalxForm);
  1134.             
  1135.             shape->Transform(ev, tempx);
  1136.  
  1137.             // ----- Intersect with content shape -----
  1138.             FW_CAcquiredODShape aqContentShape = containingFrame->AcquireContentShape(ev);
  1139.             shape->Intersect(ev, aqContentShape);
  1140.         }
  1141.         
  1142.         // ----- Call the proxy to intersect with content -----
  1143.         proxy->AdjustBorderShape(ev, containingFrame, embeddedFacet, shape);
  1144.  
  1145.         // ----- Put it back in embeddedFacet frame coordinate -----
  1146.         if (shape != NULL)
  1147.             shape->InverseTransform(ev, tempx);
  1148.     }
  1149.     FW_CATCH_BEGIN
  1150.     FW_CATCH_REFERENCE(FW_XException, exception)
  1151.     {
  1152.         FW_SetException(ev, exception);
  1153.     }
  1154.     FW_CATCH_EVERYTHING()
  1155.     {
  1156.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1157.         FW_SetEvError(ev, kODErrUndefined);
  1158.     }
  1159.     FW_CATCH_END
  1160.     
  1161.     return shape;
  1162. }
  1163.  
  1164. //---------------------------------------------------------------------------------------
  1165. //    FW_CODPart::FacetAdded
  1166. //---------------------------------------------------------------------------------------
  1167.  
  1168. void FW_CODPart::FacetAdded(Environment *ev, ODFacet* facet)
  1169. {
  1170.     FW_TRY
  1171.     {
  1172.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, facet->GetFrame(ev));
  1173.         FW_ASSERT(frame != NULL);
  1174.         
  1175.         // ----- Set the facet's part info -----
  1176.         FW_PrivCreateFacetPartInfo(ev, facet);
  1177.  
  1178.         // ----- Notify the frame -----
  1179.         frame->PrivFacetAdded(ev, facet);
  1180.     }
  1181.     FW_CATCH_BEGIN
  1182.     FW_CATCH_REFERENCE(FW_XException, exception)
  1183.     {
  1184.         FW_SetException(ev, exception);
  1185.     }
  1186.     FW_CATCH_EVERYTHING()
  1187.     {
  1188.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1189.         FW_SetEvError(ev, kODErrUndefined);
  1190.     }
  1191.     FW_CATCH_END
  1192. }
  1193.  
  1194. //---------------------------------------------------------------------------------------
  1195. //    FW_CODPart::FacetRemoved
  1196. //---------------------------------------------------------------------------------------
  1197.  
  1198. void FW_CODPart::FacetRemoved(Environment *ev, ODFacet* facet)
  1199. {
  1200.     FW_TRY
  1201.     {
  1202.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, facet->GetFrame(ev));
  1203.         FW_ASSERT(frame != NULL);
  1204.         
  1205.         // ----- Notify the frame -----
  1206.         frame->PrivFacetRemoved(ev, facet);
  1207.  
  1208.         // ----- Delete the facet part info -----
  1209.         FW_PrivDeleteFacetPartInfo(ev, facet);
  1210.     }
  1211.     FW_CATCH_BEGIN
  1212.     FW_CATCH_REFERENCE(FW_XException, exception)
  1213.     {
  1214.         FW_SetException(ev, exception);
  1215.     }
  1216.     FW_CATCH_EVERYTHING()
  1217.     {
  1218.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1219.         FW_SetEvError(ev, kODErrUndefined);
  1220.     }
  1221.     FW_CATCH_END
  1222. }
  1223.  
  1224. //---------------------------------------------------------------------------------------
  1225. //    FW_CODPart::CanvasChanged
  1226. //---------------------------------------------------------------------------------------
  1227.  
  1228. void FW_CODPart::CanvasChanged(Environment *ev, ODFacet* facet)
  1229. {
  1230.     FW_TRY
  1231.     {
  1232.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, facet->GetFrame(ev));
  1233.         FW_ASSERT(frame != NULL);
  1234.         frame->CanvasChanged(ev, facet);
  1235.     }
  1236.     FW_CATCH_BEGIN
  1237.     FW_CATCH_REFERENCE(FW_XException, exception)
  1238.     {
  1239.         FW_SetException(ev, exception);
  1240.     }
  1241.     FW_CATCH_EVERYTHING()
  1242.     {
  1243.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1244.         FW_SetEvError(ev, kODErrUndefined);
  1245.     }
  1246.     FW_CATCH_END
  1247. }
  1248.  
  1249. //---------------------------------------------------------------------------------------
  1250. //    FW_CODPart::GeometryChanged
  1251. //---------------------------------------------------------------------------------------
  1252.  
  1253. void FW_CODPart::GeometryChanged(Environment *ev,
  1254.                                     ODFacet* facet,
  1255.                                     FW_Boolean clipShapeChanged,
  1256.                                     FW_Boolean externalTransformChanged)
  1257. {
  1258.     FW_TRY
  1259.     {
  1260.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, facet->GetFrame(ev));
  1261.         FW_ASSERT(frame != NULL);
  1262.         frame->GeometryChanged(ev, facet, clipShapeChanged, externalTransformChanged);
  1263.     }
  1264.     FW_CATCH_BEGIN
  1265.     FW_CATCH_REFERENCE(FW_XException, exception)
  1266.     {
  1267.         FW_SetException(ev, exception);
  1268.     }
  1269.     FW_CATCH_EVERYTHING()
  1270.     {
  1271.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1272.         FW_SetEvError(ev, kODErrUndefined);
  1273.     }
  1274.     FW_CATCH_END
  1275. }
  1276.  
  1277. //---------------------------------------------------------------------------------------
  1278. //    FW_CODPart::Draw
  1279. //---------------------------------------------------------------------------------------
  1280.  
  1281. void FW_CODPart::Draw(Environment *ev,
  1282.                         ODFacet* facet,
  1283.                         ODShape* invalidShape)
  1284. {
  1285.     FW_TRY
  1286.     {
  1287.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, facet->GetFrame(ev));
  1288.         FW_ASSERT(frame != NULL);
  1289.         
  1290.         frame->HandleDraw(ev, facet, invalidShape);
  1291.     }
  1292.     FW_CATCH_BEGIN
  1293.     FW_CATCH_REFERENCE(FW_XException, exception)
  1294.     {
  1295.         FW_SetException(ev, exception);
  1296.     }
  1297.     FW_CATCH_EVERYTHING()
  1298.     {
  1299.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1300.         FW_SetEvError(ev, kODErrUndefined);
  1301.     }
  1302.     FW_CATCH_END
  1303. }
  1304.  
  1305. //---------------------------------------------------------------------------------------
  1306. //    FW_CODPart::CanvasUpdated
  1307. //---------------------------------------------------------------------------------------
  1308.  
  1309. void FW_CODPart::CanvasUpdated(Environment *ev, ODCanvas* canvas)
  1310. {
  1311. FW_UNUSED(canvas);
  1312.     FW_TRY
  1313.     {
  1314.         FW_DEBUG_MESSAGE("CanvasUpdate: Not Yet Implemented");
  1315.     }
  1316.     FW_CATCH_BEGIN
  1317.     FW_CATCH_REFERENCE(FW_XException, exception)
  1318.     {
  1319.         FW_SetException(ev, exception);
  1320.     }
  1321.     FW_CATCH_EVERYTHING()
  1322.     {
  1323.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1324.         FW_SetEvError(ev, kODErrUndefined);
  1325.     }
  1326.     FW_CATCH_END
  1327. }
  1328.  
  1329. //---------------------------------------------------------------------------------------
  1330. //    FW_CODPart::HighlightChanged
  1331. //---------------------------------------------------------------------------------------
  1332.  
  1333. void FW_CODPart::HighlightChanged(Environment *ev, ODFacet* facet)
  1334. {
  1335.     FW_TRY
  1336.     {
  1337.         ODHighlight to = facet->GetHighlight(ev);
  1338.         ODHighlight from = FW_PrivGetFacetHighlight(ev, facet);    // return the previous facet Highlight
  1339.         FW_PrivSetFacetHighlight(ev, facet, to);                // set previuous hilite
  1340.  
  1341.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, facet->GetFrame(ev));
  1342.         frame->HighlightChanged(ev, facet, from, to);
  1343.     }
  1344.     FW_CATCH_BEGIN
  1345.     FW_CATCH_REFERENCE(FW_XException, exception)
  1346.     {
  1347.         FW_SetException(ev, exception);
  1348.     }
  1349.     FW_CATCH_EVERYTHING()
  1350.     {
  1351.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1352.         FW_SetEvError(ev, kODErrUndefined);
  1353.     }
  1354.     FW_CATCH_END
  1355. }
  1356.  
  1357. //---------------------------------------------------------------------------------------
  1358. //    FW_CODPart::GetPrintResolution
  1359. //---------------------------------------------------------------------------------------
  1360.  
  1361. unsigned long FW_CODPart::GetPrintResolution(Environment *ev, ODFrame* odFrame)
  1362. {
  1363. FW_UNUSED(odFrame);
  1364.     ODULong resolution = 0;
  1365.     
  1366.     FW_TRY
  1367.     {
  1368.         FW_DEBUG_MESSAGE("GetPrintResolution: Not Yet Implemented");
  1369.     }
  1370.     FW_CATCH_BEGIN
  1371.     FW_CATCH_REFERENCE(FW_XException, exception)
  1372.     {
  1373.         FW_SetException(ev, exception);
  1374.     }
  1375.     FW_CATCH_EVERYTHING()
  1376.     {
  1377.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1378.         FW_SetEvError(ev, kODErrUndefined);
  1379.     }
  1380.     FW_CATCH_END
  1381.     
  1382.     return resolution;
  1383. }
  1384.  
  1385. //---------------------------------------------------------------------------------------
  1386. //    FW_CODPart::CreateLink
  1387. //---------------------------------------------------------------------------------------
  1388.  
  1389. ODLinkSource* FW_CODPart::CreateLink(Environment *ev, FW_CPart* part, ODByteArray* data)
  1390. {
  1391.     ODLinkSource* odLinkSource = NULL;
  1392.  
  1393.     FW_TRY
  1394.     {
  1395.         FW_CLinkManager* linkMgr = part->GetLinkManager(ev);
  1396.         FW_ASSERT(linkMgr);
  1397.         odLinkSource = linkMgr->CreateLink(ev, data);
  1398.     }
  1399.     FW_CATCH_BEGIN
  1400.     FW_CATCH_REFERENCE(FW_XException, exception)
  1401.     {
  1402.         FW_SetException(ev, exception);
  1403.     }
  1404.     FW_CATCH_EVERYTHING()
  1405.     {
  1406.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1407.         FW_SetEvError(ev, kODErrUndefined);
  1408.     }
  1409.     FW_CATCH_END
  1410.     
  1411.     return odLinkSource;
  1412. }
  1413.  
  1414. //---------------------------------------------------------------------------------------
  1415. //    FW_CODPart::LinkUpdated
  1416. //---------------------------------------------------------------------------------------
  1417.  
  1418. void FW_CODPart::LinkUpdated(Environment *ev,
  1419.                                 FW_CPart* part,
  1420.                                 ODLink* updatedLink,
  1421.                                 ODUpdateID updateID)
  1422. {
  1423.     FW_TRY
  1424.     {
  1425.         // Notify all the links that are destinations of the updated link
  1426.         FW_CPartLinkDestIterator iter(part);
  1427.         for (FW_CLinkDestination* link = iter.First(); iter.IsNotComplete(); link = iter.Next())
  1428.         {
  1429.             if (updatedLink->IsEqualTo(ev, link->GetODLink(ev)) && (link->IsRegistered(ev)))
  1430.             {
  1431.                 link->LinkUpdated(ev, updateID);
  1432.             }
  1433.         }
  1434.     
  1435.         // $$$$$ [MH] It would be good to avoid each link calling ContentUpdated on the frame, and do it here
  1436.         // but we don't know here what frame(s) to call it on.  The solution would be to collect a
  1437.         // list of unique frames or presentations from the links that are updated, then iterate
  1438.         // that list calling ContentUpdated once on each.
  1439.         
  1440.         // we must dirty the part!
  1441.         part->Changed(ev);
  1442.         
  1443.     }
  1444.     FW_CATCH_BEGIN
  1445.     FW_CATCH_REFERENCE(FW_XException, exception)
  1446.     {
  1447.         FW_SetException(ev, exception);
  1448.     }
  1449.     FW_CATCH_EVERYTHING()
  1450.     {
  1451.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1452.         FW_SetEvError(ev, kODErrUndefined);
  1453.     }
  1454.     FW_CATCH_END
  1455. }
  1456.  
  1457. //---------------------------------------------------------------------------------------
  1458. //    FW_CODPart::RevealLink
  1459. //---------------------------------------------------------------------------------------
  1460.  
  1461. void FW_CODPart::RevealLink(Environment *ev, FW_CPart* part, ODLinkSource* linkSource)
  1462. {
  1463.     FW_TRY
  1464.     {
  1465.         FW_CLinkManager* linkMgr = part->GetLinkManager(ev);
  1466.         FW_ASSERT(linkMgr);
  1467.         linkMgr->RevealLink(ev, linkSource);
  1468.     }
  1469.     FW_CATCH_BEGIN
  1470.     FW_CATCH_REFERENCE(FW_XException, exception)
  1471.     {
  1472.         FW_SetException(ev, exception);
  1473.     }
  1474.     FW_CATCH_EVERYTHING()
  1475.     {
  1476.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1477.         FW_SetEvError(ev, kODErrUndefined);
  1478.     }
  1479.     FW_CATCH_END
  1480. }
  1481.  
  1482. //---------------------------------------------------------------------------------------
  1483. //    FW_CODPart::EmbeddedFrameUpdated
  1484. //---------------------------------------------------------------------------------------
  1485.  
  1486. void FW_CODPart::EmbeddedFrameUpdated(Environment *ev,
  1487.                                       FW_CPart* part,
  1488.                                       ODFrame* odFrame,
  1489.                                       ODUpdateID updateID)
  1490. {
  1491.     FW_TRY
  1492.     {
  1493.         FW_CLinkManager* linkMgr = part->GetLinkManager(ev);
  1494.         if (linkMgr)
  1495.             linkMgr->DoUpdateLinks(ev, odFrame, updateID);
  1496.     }
  1497.     FW_CATCH_BEGIN
  1498.     FW_CATCH_REFERENCE(FW_XException, exception)
  1499.     {
  1500.         FW_SetException(ev, exception);
  1501.     }
  1502.     FW_CATCH_EVERYTHING()
  1503.     {
  1504.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1505.         FW_SetEvError(ev, kODErrUndefined);
  1506.     }
  1507.     FW_CATCH_END
  1508. }
  1509.  
  1510. //---------------------------------------------------------------------------------------
  1511. //    FW_CODPart::EditInLinkAttempted
  1512. //---------------------------------------------------------------------------------------
  1513.  
  1514. FW_Boolean FW_CODPart::EditInLinkAttempted(Environment *ev, FW_CPart* part, ODFrame* odFrame)
  1515. {
  1516.     FW_Boolean result = FALSE;
  1517.     
  1518.     FW_TRY
  1519.     {
  1520.         FW_CLinkManager* linkMgr = part->GetLinkManager(ev);
  1521.         FW_ASSERT(linkMgr);
  1522.         result = linkMgr->EditInLinkAttempted(ev, odFrame);
  1523.     }
  1524.     FW_CATCH_BEGIN
  1525.     FW_CATCH_REFERENCE(FW_XException, exception)
  1526.     {
  1527.         FW_SetException(ev, exception);
  1528.     }
  1529.     FW_CATCH_EVERYTHING()
  1530.     {
  1531.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1532.         FW_SetEvError(ev, kODErrUndefined);
  1533.     }
  1534.     FW_CATCH_END
  1535.     
  1536.     return result;
  1537. }
  1538.  
  1539. //---------------------------------------------------------------------------------------
  1540. //    FW_CODPart::LinkStatusChanged
  1541. //---------------------------------------------------------------------------------------
  1542.  
  1543. void FW_CODPart::LinkStatusChanged(Environment *ev, FW_CPart* part, ODFrame* odFrame)
  1544. {
  1545.     FW_TRY
  1546.     {
  1547.         FW_CLinkManager* linkMgr = part->GetLinkManager(ev);
  1548.         if (linkMgr)
  1549.             linkMgr->DoChangeLinkStatus(ev, odFrame);
  1550.         else
  1551.             part->LinkStatusChanged(ev, odFrame);
  1552.     }
  1553.     FW_CATCH_BEGIN
  1554.     FW_CATCH_REFERENCE(FW_XException, exception)
  1555.     {
  1556.         FW_SetException(ev, exception);
  1557.     }
  1558.     FW_CATCH_EVERYTHING()
  1559.     {
  1560.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1561.         FW_SetEvError(ev, kODErrUndefined);
  1562.     }
  1563.     FW_CATCH_END
  1564. }
  1565.  
  1566. //---------------------------------------------------------------------------------------
  1567. //    FW_CODPart::BeginRelinquishFocus
  1568. //---------------------------------------------------------------------------------------
  1569.  
  1570. FW_Boolean FW_CODPart::BeginRelinquishFocus(Environment *ev,
  1571.                                             FW_CPart* part,
  1572.                                             ODTypeToken focus,
  1573.                                             ODFrame* odOwnerFrame,
  1574.                                             ODFrame* proposedFrame)
  1575. {
  1576.     FW_Boolean result = FALSE;
  1577.     
  1578.     FW_TRY
  1579.     {
  1580.         if (focus == FW_CPart::fgModalFocusToken)
  1581.         {
  1582.             FW_CAcquiredODPart aqODPart = proposedFrame->AcquirePart(ev);
  1583.              return (aqODPart == part->GetODPart(ev));
  1584.         }
  1585.     
  1586.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, odOwnerFrame);
  1587.         result = frame->BeginRelinquishFocus(ev, focus, proposedFrame);
  1588.     }
  1589.     FW_CATCH_BEGIN
  1590.     FW_CATCH_REFERENCE(FW_XException, exception)
  1591.     {
  1592.         FW_SetException(ev, exception);
  1593.     }
  1594.     FW_CATCH_EVERYTHING()
  1595.     {
  1596.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1597.         FW_SetEvError(ev, kODErrUndefined);
  1598.     }
  1599.     FW_CATCH_END
  1600.     
  1601.     return result;
  1602. }
  1603.  
  1604. //---------------------------------------------------------------------------------------
  1605. //    FW_CODPart::CommitRelinquishFocus
  1606. //---------------------------------------------------------------------------------------
  1607.  
  1608. void FW_CODPart::CommitRelinquishFocus(Environment *ev,
  1609.                                         ODTypeToken focus,
  1610.                                         ODFrame* odOwnerFrame,
  1611.                                         ODFrame* odProposedFrame)
  1612. {
  1613.     FW_TRY
  1614.     {
  1615.         FW_CFrame* ownerFrame = FW_CFrame::ODtoFWFrame(ev, odOwnerFrame);
  1616.         FW_ASSERT(ownerFrame != NULL);
  1617.     
  1618.         ownerFrame->FocusStateChanged(ev, focus, FALSE, odProposedFrame);
  1619.     }
  1620.     FW_CATCH_BEGIN
  1621.     FW_CATCH_REFERENCE(FW_XException, exception)
  1622.     {
  1623.         FW_SetException(ev, exception);
  1624.     }
  1625.     FW_CATCH_EVERYTHING()
  1626.     {
  1627.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1628.         FW_SetEvError(ev, kODErrUndefined);
  1629.     }
  1630.     FW_CATCH_END
  1631. }
  1632.  
  1633. //---------------------------------------------------------------------------------------
  1634. //    FW_CODPart::AbortRelinquishFocus
  1635. //---------------------------------------------------------------------------------------
  1636.  
  1637. void FW_CODPart::AbortRelinquishFocus(Environment *ev,
  1638.                                         ODTypeToken focus,
  1639.                                         ODFrame* ownerFrame,
  1640.                                         ODFrame* proposedFrame)
  1641. {
  1642.     FW_TRY
  1643.     {
  1644.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, ownerFrame);
  1645.         FW_ASSERT(frame);
  1646.         
  1647.         frame->AbortRelinquishFocus(ev, focus, proposedFrame);
  1648.     }
  1649.     FW_CATCH_BEGIN
  1650.     FW_CATCH_REFERENCE(FW_XException, exception)
  1651.     {
  1652.         FW_SetException(ev, exception);
  1653.     }
  1654.     FW_CATCH_EVERYTHING()
  1655.     {
  1656.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1657.         FW_SetEvError(ev, kODErrUndefined);
  1658.     }
  1659.     FW_CATCH_END
  1660. }
  1661.  
  1662. //---------------------------------------------------------------------------------------
  1663. //    FW_CODPart::FocusAcquired
  1664. //---------------------------------------------------------------------------------------
  1665.  
  1666. void FW_CODPart::FocusAcquired(Environment *ev,
  1667.                                 ODTypeToken focus,
  1668.                                 ODFrame* ownerFrame)
  1669. {
  1670.     FW_TRY
  1671.     {
  1672.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, ownerFrame);
  1673.         FW_ASSERT(frame != NULL);
  1674.         
  1675.         frame->FocusStateChanged(ev, focus, TRUE, NULL);
  1676.     }
  1677.     FW_CATCH_BEGIN
  1678.     FW_CATCH_REFERENCE(FW_XException, exception)
  1679.     {
  1680.         FW_SetException(ev, exception);
  1681.     }
  1682.     FW_CATCH_EVERYTHING()
  1683.     {
  1684.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1685.         FW_SetEvError(ev, kODErrUndefined);
  1686.     }
  1687.     FW_CATCH_END
  1688. }
  1689.  
  1690. //---------------------------------------------------------------------------------------
  1691. //    FW_CODPart::FocusLost
  1692. //---------------------------------------------------------------------------------------
  1693.  
  1694. void FW_CODPart::FocusLost(Environment *ev,
  1695.                             ODTypeToken focus,
  1696.                             ODFrame* ownerFrame)
  1697. {
  1698.     FW_TRY
  1699.     {
  1700.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, ownerFrame);
  1701.         FW_ASSERT(frame != NULL);
  1702.         
  1703.         frame->FocusStateChanged(ev, focus, FALSE, NULL);
  1704.     }
  1705.     FW_CATCH_BEGIN
  1706.     FW_CATCH_REFERENCE(FW_XException, exception)
  1707.     {
  1708.         FW_SetException(ev, exception);
  1709.     }
  1710.     FW_CATCH_EVERYTHING()
  1711.     {
  1712.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1713.         FW_SetEvError(ev, kODErrUndefined);
  1714.     }
  1715.     FW_CATCH_END
  1716. }
  1717.  
  1718. //---------------------------------------------------------------------------------------
  1719. //    FW_CODPart::CloneInto
  1720. //---------------------------------------------------------------------------------------
  1721.  
  1722. void FW_CODPart::CloneInto(Environment *ev,
  1723.                             FW_CPart* part,
  1724.                             ODDraftKey key,
  1725.                             ODStorageUnit* toSU,
  1726.                             ODFrame* scope)
  1727. {
  1728.     FW_TRY
  1729.     {
  1730.         // Since this method may be called multiple times during one Cloning
  1731.         // transaction, the Part should check to see whether it really needs
  1732.         // to write out any data
  1733.         if (toSU->Exists(ev, kODPropContents, part->GetPartKind(ev)->GetType(ev), 0))
  1734.             return;
  1735.     
  1736.         // Add Content Property if not exist
  1737.         if (!toSU->Exists(ev, kODPropContents, NULL, 0))
  1738.             toSU->AddProperty(ev, kODPropContents);
  1739.         
  1740.         part->CloneInto(ev, key, toSU, scope);
  1741.     }
  1742.     FW_CATCH_BEGIN
  1743.     FW_CATCH_REFERENCE(FW_XException, exception)
  1744.     {
  1745.         FW_SetException(ev, exception);
  1746.     }
  1747.     FW_CATCH_EVERYTHING()
  1748.     {
  1749.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1750.         FW_SetEvError(ev, kODErrUndefined);
  1751.     }
  1752.     FW_CATCH_END
  1753. }
  1754.  
  1755. //---------------------------------------------------------------------------------------
  1756. //    FW_CODPart::ExternalizeKinds
  1757. //---------------------------------------------------------------------------------------
  1758.  
  1759. void FW_CODPart::ExternalizeKinds(Environment *ev, FW_CPart* part, ODTypeList* kindset)
  1760. {
  1761.     FW_TRY
  1762.     {
  1763.         part->ExternalizeKinds(ev, kindset);
  1764.     }
  1765.     FW_CATCH_BEGIN
  1766.     FW_CATCH_REFERENCE(FW_XException, exception)
  1767.     {
  1768.         FW_SetException(ev, exception);
  1769.     }
  1770.     FW_CATCH_EVERYTHING()
  1771.     {
  1772.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1773.         FW_SetEvError(ev, kODErrUndefined);
  1774.     }
  1775.     FW_CATCH_END
  1776. }
  1777.  
  1778. //---------------------------------------------------------------------------------------
  1779. //    FW_CODPart::ChangeKind
  1780. //---------------------------------------------------------------------------------------
  1781.  
  1782. void FW_CODPart::ChangeKind(Environment *ev, FW_CPart* part, ODType kind)
  1783. {
  1784.     FW_TRY
  1785.     {
  1786.         part->ChangeKind(ev, kind);
  1787.     }
  1788.     FW_CATCH_BEGIN
  1789.     FW_CATCH_REFERENCE(FW_XException, exception)
  1790.     {
  1791.         FW_SetException(ev, exception);
  1792.     }
  1793.     FW_CATCH_EVERYTHING()
  1794.     {
  1795.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1796.         FW_SetEvError(ev, kODErrUndefined);
  1797.     }
  1798.     FW_CATCH_END
  1799. }
  1800.  
  1801. //---------------------------------------------------------------------------------------
  1802. //    FW_CODPart::HandleEvent
  1803. //---------------------------------------------------------------------------------------
  1804.  
  1805. FW_Boolean FW_CODPart::HandleEvent(Environment *ev,
  1806.                                     FW_CPart* part,
  1807.                                     ODEventData* event,
  1808.                                     ODFrame* odFrame,
  1809.                                     ODFacet* odFacet,
  1810.                                     ODEventInfo* eventInfo)
  1811. {
  1812.     //     Set the default value to TRUE so if Dispatch fails while trying to handle the
  1813.     //    event I will still returns true. Dispatch will anyway returns FALSE if I don't
  1814.     //    handle the event. It is unlikely that I will fail in not handling the event.
  1815.     FW_Boolean handled = TRUE;
  1816.     
  1817.     FW_TRY
  1818.     {
  1819.         FW_CFrame* fwFrame = NULL;
  1820.         if (odFrame != NULL) {
  1821.             fwFrame = FW_CFrame::ODtoFWFrame(ev, odFrame);
  1822.             
  1823.             // mlanett: Cyberdog 1.0 is sending us events with bogus ODFrames
  1824.             #ifdef FW_BUILD_MAC    
  1825.                 if (event->what == kODEvtMenu && fwFrame == NULL)
  1826.             #endif
  1827.             #ifdef FW_BUILD_WIN    
  1828.                 if (event->message == kODEvtMenu && fwFrame == NULL)
  1829.             #endif
  1830.                     return FW_kNotHandled;
  1831.                 
  1832.             FW_ASSERT(fwFrame);
  1833.         }
  1834.         
  1835.         handled = (part->GetEventDispatcher(ev)->Dispatch(ev, event, fwFrame, odFacet, eventInfo) == FW_kHandled);
  1836.     }
  1837.     FW_CATCH_BEGIN
  1838.     FW_CATCH_REFERENCE(FW_XException, exception)
  1839.     {
  1840.         FW_SetException(ev, exception);
  1841.     }
  1842.     FW_CATCH_EVERYTHING()
  1843.     {
  1844.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1845.         FW_SetEvError(ev, kODErrUndefined);
  1846.     }
  1847.     FW_CATCH_END
  1848.     
  1849.     return handled;
  1850. }
  1851.  
  1852. //---------------------------------------------------------------------------------------
  1853. //    FW_CODPart::AdjustMenus
  1854. //---------------------------------------------------------------------------------------
  1855.  
  1856. void FW_CODPart::AdjustMenus(Environment *ev, FW_CPart* part, ODFrame* odFrame)
  1857. {
  1858.     FW_TRY
  1859.     {
  1860.         FW_CFrame *frame = FW_CFrame::ODtoFWFrame(ev, odFrame);
  1861.         FW_ASSERT(frame != NULL);
  1862.         
  1863.         // ----- Look if this frame has the menuFocus -----
  1864.         ODArbitrator* arbitrator = FW_CSession::GetArbitrator(ev);
  1865.         FW_CAcquiredODFrame aqFrameWithFocus = arbitrator->AcquireFocusOwner(ev, FW_CPart::fgMenuFocusToken);
  1866.         
  1867.         FW_CMenuBar *menuBar = part->GetMenuBar(ev);
  1868.         menuBar->DisableAll(ev);
  1869.     
  1870.         FW_Boolean hasMenuFocus = (aqFrameWithFocus == odFrame);
  1871.         FW_Boolean rootFrame = frame->IsRoot(ev);
  1872.  
  1873.         FW_MEventHandler* target = frame->GetTarget(ev);
  1874.         FW_Boolean handled = FALSE;
  1875.         while (target != NULL && handled == FALSE)
  1876.         {
  1877.             handled = target->PrivDispatchAdjustMenus(ev, menuBar, hasMenuFocus, rootFrame);
  1878.                 
  1879.             target = target->GetNextEventHandler(ev);
  1880.         }
  1881.     }
  1882.     FW_CATCH_BEGIN
  1883.     FW_CATCH_REFERENCE(FW_XException, exception)
  1884.     {
  1885.         FW_SetException(ev, exception);
  1886.     }
  1887.     FW_CATCH_EVERYTHING()
  1888.     {
  1889.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1890.         FW_SetEvError(ev, kODErrUndefined);
  1891.     }
  1892.     FW_CATCH_END
  1893. }
  1894.  
  1895. //---------------------------------------------------------------------------------------
  1896. //    FW_CODPart::UndoAction
  1897. //---------------------------------------------------------------------------------------
  1898.  
  1899. void FW_CODPart::UndoAction(Environment *ev, FW_CPart* part, ODActionData* actionState)
  1900. {
  1901. FW_UNUSED(part);
  1902.     FW_TRY
  1903.     {
  1904.         // actionState may contain a pointer to the command object
  1905.         if (actionState->_maximum == sizeof(FW_CCommand*))
  1906.         {
  1907.             FW_CCommand* command = *(FW_CCommand**)actionState->_buffer;
  1908.             FW_ASSERT(command);
  1909.             if (command)    // [EXERPART] Should not happen but the exerPart calls me with nothing to undo
  1910.                 command->HandleUndo(ev);
  1911.         }
  1912.     }
  1913.     FW_CATCH_BEGIN
  1914.     FW_CATCH_REFERENCE(FW_XException, exception)
  1915.     {
  1916.         FW_SetException(ev, exception);
  1917.     }
  1918.     FW_CATCH_EVERYTHING()
  1919.     {
  1920.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1921.         FW_SetEvError(ev, kODErrUndefined);
  1922.     }
  1923.     FW_CATCH_END
  1924. }
  1925.  
  1926. //---------------------------------------------------------------------------------------
  1927. //    FW_CODPart::RedoAction
  1928. //---------------------------------------------------------------------------------------
  1929.  
  1930. void FW_CODPart::RedoAction(Environment *ev, ODActionData* actionState)
  1931. {
  1932.     FW_TRY
  1933.     {
  1934.         // actionState may contain a pointer to the command object
  1935.         if (actionState->_maximum == sizeof(FW_CCommand*))
  1936.         {
  1937.             FW_CCommand* command = *(FW_CCommand**)actionState->_buffer;
  1938.             FW_ASSERT(command);
  1939.             if (command)    // [EXERPART] Should not happen but the exerPart calls me with nothing to undo
  1940.                 command->HandleRedo(ev);
  1941.         }
  1942.     }
  1943.     FW_CATCH_BEGIN
  1944.     FW_CATCH_REFERENCE(FW_XException, exception)
  1945.     {
  1946.         FW_SetException(ev, exception);
  1947.     }
  1948.     FW_CATCH_EVERYTHING()
  1949.     {
  1950.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1951.         FW_SetEvError(ev, kODErrUndefined);
  1952.     }
  1953.     FW_CATCH_END
  1954. }
  1955.  
  1956. //---------------------------------------------------------------------------------------
  1957. //    FW_CODPart::DisposeActionState
  1958. //---------------------------------------------------------------------------------------
  1959.  
  1960. void FW_CODPart::DisposeActionState(Environment *ev,
  1961.                                     ODActionData* actionState,
  1962.                                     ODDoneState doneState)
  1963. {
  1964.     FW_TRY
  1965.     {
  1966.         // actionState may contain a pointer to the command object
  1967.         if (actionState->_maximum == sizeof(FW_CCommand*))
  1968.         {
  1969.             FW_CCommand* command = *(FW_CCommand**)actionState->_buffer;
  1970.             FW_ASSERT(command);
  1971.             if (command == NULL)    // [EXERPART] Should not happen but the exerPart calls me with nothing to undo
  1972.                 return;
  1973.                 
  1974.             if (doneState == kODUndone)
  1975.                 command->CommitUndone(ev);
  1976.             else    // doneState is kODDone or kODRedone
  1977.                 command->CommitDone(ev);
  1978.             delete command;
  1979.         }
  1980.     }
  1981.     FW_CATCH_BEGIN
  1982.     FW_CATCH_REFERENCE(FW_XException, exception)
  1983.     {
  1984.         FW_SetException(ev, exception);
  1985.     }
  1986.     FW_CATCH_EVERYTHING()
  1987.     {
  1988.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1989.         FW_SetEvError(ev, kODErrUndefined);
  1990.     }
  1991.     FW_CATCH_END
  1992. }
  1993.  
  1994. //---------------------------------------------------------------------------------------
  1995. //    FW_CODPart::WriteActionState
  1996. //---------------------------------------------------------------------------------------
  1997.  
  1998. void FW_CODPart::WriteActionState(Environment *ev,
  1999.                                     ODActionData* actionState,
  2000.                                     ODStorageUnitView* storageUnitView)
  2001. {
  2002. FW_UNUSED(actionState);
  2003. FW_UNUSED(storageUnitView);
  2004.     FW_TRY
  2005.     {
  2006.         FW_DEBUG_MESSAGE("WriteActionState: Not Yet Implemented");
  2007.     }
  2008.     FW_CATCH_BEGIN
  2009.     FW_CATCH_REFERENCE(FW_XException, exception)
  2010.     {
  2011.         FW_SetException(ev, exception);
  2012.     }
  2013.     FW_CATCH_EVERYTHING()
  2014.     {
  2015.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  2016.         FW_SetEvError(ev, kODErrUndefined);
  2017.     }
  2018.     FW_CATCH_END
  2019. }
  2020.  
  2021. //---------------------------------------------------------------------------------------
  2022. //    FW_CODPart::ReadActionState
  2023. //---------------------------------------------------------------------------------------
  2024.  
  2025. void FW_CODPart::ReadActionState(Environment *ev, ODStorageUnitView* storageUnitView, ODActionData* actionData)
  2026. {
  2027. FW_UNUSED(storageUnitView);
  2028. FW_UNUSED(actionData);
  2029.     FW_TRY
  2030.     {
  2031.          FW_DEBUG_MESSAGE("ReadActionState: Not Yet Implemented");
  2032.     }
  2033.     FW_CATCH_BEGIN
  2034.     FW_CATCH_REFERENCE(FW_XException, exception)
  2035.     {
  2036.         FW_SetException(ev, exception);
  2037.     }
  2038.     FW_CATCH_EVERYTHING()
  2039.     {
  2040.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  2041.         FW_SetEvError(ev, kODErrUndefined);
  2042.     }
  2043.     FW_CATCH_END
  2044. }
  2045.  
  2046. //---------------------------------------------------------------------------------------
  2047. //    FW_CODPart::InitPart
  2048. //---------------------------------------------------------------------------------------
  2049.  
  2050. void FW_CODPart::InitPart(Environment *ev,
  2051.                         FW_CPart* part,
  2052.                         ODStorageUnit* storageUnit)
  2053. {        
  2054. FW_UNUSED(storageUnit);
  2055.     
  2056.     FW_TRY
  2057.     {
  2058.         // ----- Common initialization -----
  2059.         part->Initialize(ev, storageUnit, FALSE);
  2060.     
  2061.         part->PrivSetDirty(ev, TRUE);
  2062.     }
  2063.     FW_CATCH_BEGIN
  2064.     FW_CATCH_REFERENCE(FW_XException, exception)
  2065.     {
  2066.         FW_SetException(ev, exception);
  2067.     }
  2068.     FW_CATCH_EVERYTHING()
  2069.     {
  2070.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  2071.         FW_SetEvError(ev, kODErrUndefined);
  2072.     }
  2073.     FW_CATCH_END
  2074. }
  2075.  
  2076. //---------------------------------------------------------------------------------------
  2077. //    FW_CODPart::InitPartFromStorage
  2078. //---------------------------------------------------------------------------------------
  2079.  
  2080. void FW_CODPart::InitPartFromStorage(Environment *ev,
  2081.                                     FW_CPart* part,
  2082.                                     ODStorageUnit* storageUnit)
  2083. {
  2084.     FW_TRY
  2085.     {
  2086.         // ----- Common initialization -----
  2087.         part->Initialize(ev, storageUnit, TRUE);
  2088.         
  2089.         // ----- Determine the preferred kind -----
  2090.         part->PrivDeterminePreferredKind(ev, storageUnit);
  2091.         
  2092.         // ----- Read Part Specific data -----
  2093.         part->InternalizeContent(ev, storageUnit, NULL);
  2094.     }
  2095.     FW_CATCH_BEGIN
  2096.     FW_CATCH_REFERENCE(FW_XException, exception)
  2097.     {
  2098.         FW_SetException(ev, exception);
  2099.     }
  2100.     FW_CATCH_EVERYTHING()
  2101.     {
  2102.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  2103.         FW_SetEvError(ev, kODErrUndefined);
  2104.     }
  2105.     FW_CATCH_END
  2106. }
  2107.  
  2108. //---------------------------------------------------------------------------------------
  2109. //    FW_CODPart::Externalize
  2110. //---------------------------------------------------------------------------------------
  2111.  
  2112. void FW_CODPart::Externalize(Environment *ev, FW_CPart* part)
  2113. {
  2114.     FW_TRY
  2115.     {
  2116.         part->ExternalizeContent(ev, part->GetStorageUnit(ev), NULL);
  2117.     }
  2118.     FW_CATCH_BEGIN
  2119.     FW_CATCH_REFERENCE(FW_XException, exception)
  2120.     {
  2121.         FW_SetException(ev, exception);
  2122.     }
  2123.     FW_CATCH_EVERYTHING()
  2124.     {
  2125.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  2126.         FW_SetEvError(ev, kODErrUndefined);
  2127.     }
  2128.     FW_CATCH_END
  2129. }
  2130.  
  2131. //---------------------------------------------------------------------------------------
  2132. //    FW_CODPart::Release
  2133. //---------------------------------------------------------------------------------------
  2134.  
  2135. void FW_CODPart::Release(Environment *ev, FW_CPart* part)
  2136. {
  2137.     FW_TRY
  2138.     {
  2139.         part->Release(ev);
  2140.     }
  2141.     FW_CATCH_BEGIN
  2142.     FW_CATCH_REFERENCE(FW_XException, exception)
  2143.     {
  2144.         FW_SetException(ev, exception);
  2145.     }
  2146.     FW_CATCH_EVERYTHING()
  2147.     {
  2148.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  2149.         FW_SetEvError(ev, kODErrUndefined);
  2150.     }
  2151.     FW_CATCH_END
  2152. }
  2153.  
  2154. //---------------------------------------------------------------------------------------
  2155. //    FW_CODPart::ReleaseAll
  2156. //---------------------------------------------------------------------------------------
  2157.  
  2158. void FW_CODPart::ReleaseAll(Environment *ev, FW_CPart* part)
  2159. {
  2160.     FW_TRY
  2161.     {
  2162.         part->ReleaseAll(ev);
  2163.     }
  2164.     FW_CATCH_BEGIN
  2165.     FW_CATCH_REFERENCE(FW_XException, exception)
  2166.     {
  2167.         FW_SetException(ev, exception);
  2168.     }
  2169.     FW_CATCH_EVERYTHING()
  2170.     {
  2171.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  2172.         FW_SetEvError(ev, kODErrUndefined);
  2173.     }
  2174.     FW_CATCH_END
  2175. }
  2176.  
  2177. //---------------------------------------------------------------------------------------
  2178. //    FW_CODPart::Purge
  2179. //---------------------------------------------------------------------------------------
  2180.  
  2181. ODSize FW_CODPart::Purge(Environment *ev, FW_CPart* part, ODSize size)
  2182. {
  2183.     ODSize bytesFreed = 0;
  2184.     
  2185.     FW_TRY
  2186.     {
  2187.         bytesFreed = part->Purge(ev, size);
  2188.     }
  2189.     FW_CATCH_BEGIN
  2190.     FW_CATCH_REFERENCE(FW_XException, exception)
  2191.     {
  2192.         FW_SetException(ev, exception);
  2193.     }
  2194.     FW_CATCH_EVERYTHING()
  2195.     {
  2196.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  2197.         FW_SetEvError(ev, kODErrUndefined);
  2198.     }
  2199.     FW_CATCH_END
  2200.     
  2201.     return bytesFreed;
  2202. }
  2203.